package com.example.iorder.restaurant;


import com.example.iorder.R;

import android.app.TabActivity;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class RestaurantDetailsTabHost extends TabActivity implements OnTabChangeListener {
	
	TabHost tabHost;
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.restaurant_tab_details);
		
		Resources ressources = getResources(); 
		 tabHost = getTabHost(); 
		tabHost.setOnTabChangedListener(this);
		
		// Indicator text moet nog in resources komen
		// General Tab
		Intent intentGeneralInformation = new Intent().setClass(this, RestaurantDetails_GeneralInformation.class);
		TabSpec tabGeneralInformation = tabHost
			.newTabSpec("Algemeen")
			.setIndicator("Algemeen")
			.setContent(intentGeneralInformation);
		Bundle bundle = getIntent().getExtras();
		//bundle.putInt(getResources().getString(R.string.key_restaurant_id), 11);
		intentGeneralInformation.putExtras(bundle);

		// Indicator text moet nog in resources komen
		// Opening Hours Tab
		Intent intentOpeningHours = new Intent().setClass(this, RestaurantDetails_OpeningHours.class);
		TabSpec tabOpeningHours = tabHost
			.newTabSpec("Openingstijden")
			.setIndicator("Openingstijden")
			.setContent(intentOpeningHours);
		intentOpeningHours.putExtras(bundle);
		
		Intent intentMaps = new Intent().setClass(this, RestaurantDetails_Maps.class);
		TabSpec tabMaps = tabHost
			.newTabSpec("Maps")
			.setIndicator("Maps")
			.setContent(intentMaps);
		
		Intent intentMenuCard = new Intent().setClass(this, showMenuCard.class);
		TabSpec tabMenuCard = tabHost
				.newTabSpec("MenuCard")
				.setIndicator("Menukaart")
				.setContent(intentMenuCard);
		intentMenuCard.putExtras(bundle);
			
		
		tabHost.addTab(tabGeneralInformation);
		tabHost.addTab(tabOpeningHours);
		tabHost.addTab(tabMenuCard);
		tabHost.addTab(tabMaps);
		
		tabHost.setCurrentTab(0);
		//setTabColor(tabHost);
		for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
		{
        	tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#003399"));
		}
        tabHost.getTabWidget().setCurrentTab(0);
        tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#0099CC"));

		
	}


	public void onTabChanged(String tabId) {
		// TODO Auto-generated method stub
	    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
		{
			tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#003399"));
		}

		tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#0099CC"));
		

	}
}
